//LCP 61.气温变化趋势
//https://leetcode.cn/problems/6CE719/description/
class Solution {
public:
    int temperatureTrend(vector<int>& temperatureA, vector<int>& temperatureB) {
        //-1 表示下降
        //0  表示平稳
        //1  表示上升

        function<int(int,int)> comp = [](int x,int y){
            if(x<y) return 1;
            else if(x > y) return -1;

            return 0;
        };

        int n = temperatureA.size();
        int ret = 0;
        int cnt = 0;
        for(int i = 1;i<n;++i)
        {
            int numA = comp(temperatureA[i-1],temperatureA[i]);
            int numB = comp(temperatureB[i-1],temperatureB[i]);
            if(numA == numB)
            {
                ++cnt;
                ret = max(ret,cnt);
            }
            else cnt = 0;
        }
        return ret;
    }
};